package cn.tedu.yushougeproduct.service.impl;

import cn.tedu.yushouge.commons.ex.ServiceException;
import cn.tedu.yushouge.commons.web.ServiceCode;
import cn.tedu.yushougeproduct.mapper.StateMapper;
import cn.tedu.yushougeproduct.pojo.vo.ShoppingCartStandardVO;
import cn.tedu.yushougeproduct.pojo.vo.StateListItemVO;
import cn.tedu.yushougeproduct.pojo.vo.StateStandardVO;
import cn.tedu.yushougeproduct.service.IStateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class StateServiceImpl implements IStateService {

    public StateServiceImpl() {
        log.info("创建业务对象：StateServiceImpl");
    }

    @Autowired
    StateMapper stateMapper;

    @Override
    public StateStandardVO getStandardById(Long id) {
        log.debug("开始处理【根据ID查询状态详情】的业务，参数：{}", id);
        StateStandardVO queryResult = stateMapper.getStandardById(id);
        if (queryResult == null){
            String message = "查询状态详情失败，状态数据不存在！";
            log.warn(message);
            throw new ServiceException(ServiceCode.ERR_NOT_FOUND, message);
        }
        return queryResult;
    }

    @Override
    public List<StateListItemVO> getStateDetails() {
        log.debug("开始处理【查询状态列表】的业务");
        return stateMapper.getStateDetails();
    }

}
